﻿using System;
using System.Web;
using System.Web.UI;
using System.Data;
using System.Configuration;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Collections;
using Dcms.BLL;
using Dcms.Model;
using Dcms.Common;

public partial class Manage_Modle_Position_CandList : System.Web.UI.Page
{
    public CompetenceLib CL = new CompetenceLib();
    Dcms_CandidateRecordBLL cBll = new Dcms_CandidateRecordBLL();
    public string ROLESTR = "POSITION";
    protected void Page_Load(object sender, EventArgs e)
    {
        
        CL.IsLogin();
        //try
        //{
            if (!IsPostBack)
            {        
                this.hidAmount.Value = cBll.GetDataCount("select count(*) from Dcms_CandidateRecord").ToString();
                this.hidSql.Value = "select Position_Name,Position_Id,Js_RealName,Js_Id,Js_Sex,Cr_AddTime,Cr_Id,Cr_State from Dcms_Position,Dcms_JobSeeker,Dcms_CandidateRecord Where Js_Id=Cr_jId And Position_Id=Cr_pId";
                ReBinder(1);
            }
        //}
        //catch (Exception ex)
        //{
        //    Log.LogHandler.LogError("Manage_Modle_Position_CandList.Page_Load", ex);
        //    throw ex;
        //}
    }
    protected void BindRpt(object sender, PagingEventArgs e)
    {
        this.ReBinder(e.pageIndex);
    }

    private void ReBinder(int PageIndex)
    {
        this.repIntor.DataSource = cBll.GetDataListByPage(this.hidSql.Value, PageIndex, 11);
        this.repIntor.DataBind();
        pagingctrl.InitPc(Convert.ToInt32(this.hidAmount.Value), PageIndex, 11);
    }

    public String GetStrLeng(String Str)
    {
        return Utils.GetSubString(Str, 30, "...");
    }
    public String FormatDateTimeMy(String Str)
    {
        return Convert.ToDateTime(Str).ToString("yyyy-MM-dd");
    }

    protected void repnew_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
        {
            Literal lit = (Literal)e.Item.FindControl("lit_Sex");
            if (Convert.ToInt32(DataBinder.Eval(e.Item.DataItem, "Js_Sex")) == 1)
            {
                lit.Text = "男";
            }
            else
            {
                lit.Text = "女";
            }
            ((LinkButton)e.Item.FindControl("HypDelete")).Attributes.Add
                   ("onclick", "return confirm('确定要删除该记录吗？');");
            if (CL.IsDelete(Convert.ToInt32(strCatID)) == false)
            {
                ((LinkButton)e.Item.FindControl("HypDelete")).Visible = false;
            }
        }
    }

    protected void repnew_ItemCommand(object source, System.Web.UI.WebControls.RepeaterCommandEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
        {
            if (e.CommandName == "delete")
            {
                cBll.DeleteModelByID(Convert.ToInt32(((HiddenField)e.Item.FindControl("hidID")).Value));
                Response.Redirect("CandList.aspx",false);
            }
        }
    }
    protected void btnDelete_Click(object sender, EventArgs e)
    {
        string AllID = DcmsRequest.GetFormString("ID");
        if (AllID.Trim().Length > 0)
        {
            cBll.DeleteAllCheck(AllID);
            Response.Redirect("CandList.aspx", false);
        }
        else
        {
            Jscript.AlertAndBack("没有选中项");
        }
    }
    protected void btnPass_Click(object sender, EventArgs e)
    {
        string AllID = DcmsRequest.GetFormString("ID");
        if (AllID.Trim().Length > 0)
        {
            cBll.UpdateState(AllID, 1);
            Response.Redirect("CandList.aspx", false);
        }
        else
        {
            Jscript.AlertAndBack("没有选中项");
        }
    }
    protected void btnCancel_Click(object sender, EventArgs e)
    {
        string AllID = DcmsRequest.GetFormString("ID");
        if (AllID.Trim().Length > 0)
        {
            cBll.UpdateState(AllID, 0);
            Response.Redirect("CandList.aspx", false);
        }
        else
        {
            Jscript.AlertAndBack("没有选中项");
        }
    }
	private string strCatID
    {
        get
        {
            return Request.QueryString["CatID"] + "";
        }
    }
}
